package ru;

import com.mysql.jdbc.Driver;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import java.sql.SQLException;
import java.util.Properties;

import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class Connect {

	private JTextField db = new JTextField("LightERP");
	private JTextField ipport = new JTextField("95.172.144.114:3306");
	private JTextField sid = new JTextField("mysql");
	private JTextField name = new JTextField("root");
	private JTextField passwd = new JPasswordField("ghjcnj");
	
	
	public static void main(String[] args) throws Exception {
	    /*DriverManager.registerDriver(new Driver());

	    // Print out all loaded JDBC drivers.
	    java.util.Enumeration e = java.sql.DriverManager.getDrivers();
	    while (e.hasMoreElements()) {
	      Object driverAsObject = e.nextElement();
	      System.out.println("JDBC Driver=" + driverAsObject);
	    }*/
	    
	    Properties properties = new java.util.Properties();
	    properties.put("user", "root");
	    properties.put("password","ghjcnj");
	    properties.put("useUnicode","true");
	    properties.put("characterEncoding","utf8");
	    String databaseURL = "jdbc:mysql://95.172.144.114/LightERP";
	    //DriverManager.registerDriver(new Driver());
	    Connection conn = DriverManager.getConnection(databaseURL, properties);

        Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
        
        //stmt.executeUpdate("INSERT INTO `LightERP`.`users` (`group_id`, `info`) VALUES ('3','kodabra');");
        stmt.executeUpdate("INSERT INTO `LightERP`.`users` (`user_id` ,	`firstname` ,`lastname` ,`pass` ,`phone`)VALUES (NULL , '1', '1', '1', '1');");
	  }

}
